﻿namespace Lilium.Web.Mvc.Html

open System.Runtime.CompilerServices

[<Extension>]
module FieldSet = 
    
    open System.Web.Mvc

    let fieldSet (html : HtmlHelper) (legend : MvcHtmlString) (content : MvcHtmlString) =
        let legendBuilder = TagBuilder("legend")
        legendBuilder.InnerHtml <- legend.ToHtmlString()

        let fieldsetBuilder = TagBuilder ("fieldset")
        fieldsetBuilder.InnerHtml <- 
            MvcHtmlString.Create(legendBuilder.ToString()).ToHtmlString() + 
            content.ToHtmlString()

        MvcHtmlString.Create(fieldsetBuilder.ToString())

    [<Extension>]
    let FieldSet (html, legend, content) = fieldSet html legend content 